package com.org.controller.pc;

import com.org.result.Result;
import com.org.service.EmailService;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/pc/email")
@RequiredArgsConstructor
public class EmailController {

    private final EmailService emailService;

    /**
     * 发送邮件
     * @param email 邮箱
     * @return
     */
    @GetMapping("/email")
    public Result sendEmail(@RequestParam("email") String email) {
        boolean result = emailService.sendEmail(email);
        return Result.success(result);
    }

    /**
     * 验证验证码
     * @param email 邮箱
     * @param code 验证码
     * @return
     */
    @GetMapping("/check")
    @Operation(summary = "验证验证码")
    public boolean checkCode(@RequestParam("email") String email, @RequestParam("code") String code){
        return emailService.verifyCode(email, code);
    }

}
